home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / BoxMaker++ / Monochromize ƒ / Monochromize.cp < prev    next >
Encoding:
Text File  |  1995-01-20  |  2.1 KB  |  108 lines  |  [TEXT/KAHL]

  1. #include <assert.h>
  2.  
  3. #include <fstream.h>
  4.  
  5. #include <Types.h>
  6. #include <Memory.h>
  7. #include <QuickDraw.h>
  8. #include <OSUtils.h>
  9. #include <ToolUtils.h>
  10. #include <Menus.h>
  11. #include <Packages.h>
  12. #include <Traps.h>
  13. #include <Files.h>
  14. #include <Aliases.h>
  15. #include <AppleEvents.h>
  16. #include <GestaltEqu.h>
  17. #include <Processes.h>
  18. #include <Fonts.h>
  19. #include <OSEvents.h>
  20. #include <Resources.h>
  21. #include <Desk.h>
  22.  
  23. #include <Windows.h>
  24. #include <QDOffscreen.h>
  25. #include <SegLoad.h>
  26. #include <TextEdit.h>
  27.  
  28. #include "grafport.h"
  29. #include "gworld.h"
  30.  
  31. #include "boxmaker constants.h"
  32. #include "boxmaker.h"
  33. #include "Monochromize.h"
  34.  
  35. void main();
  36.  
  37. void main()
  38. {
  39.     eight_to_one it;
  40.     it.run();
  41. }
  42.  
  43. void eight_to_one::OpenDoc( Boolean opening)
  44. {
  45.     short refNum;
  46.     FSpOpenDF( &theFSSpec, fsRdWrPerm, &refNum);
  47.     
  48.     long picture_size;
  49.     OSErr result;
  50.     
  51.     result = GetEOF( refNum, &picture_size);
  52.     
  53.     picture_size -= 0x0200;
  54.  
  55.     result = SetFPos( refNum, fsFromStart, 0x0200); 
  56.  
  57.     PicHandle thePICT = (PicHandle)NewHandle( picture_size);
  58.     HLock( (Handle)thePICT);
  59.         result = FSRead( refNum, &picture_size, (char *)*thePICT);
  60.         Rect PICTRect = (**thePICT).picFrame;
  61.     HUnlock( (Handle)thePICT);
  62.     
  63.     OffsetRect( &PICTRect, -PICTRect.left, -PICTRect.top);
  64.     
  65.     gworld offscreen( PICTRect.right, PICTRect.bottom, 1);
  66.     offscreen.use();
  67.     DrawPicture( thePICT, &PICTRect);
  68.     DisposHandle( (Handle)thePICT);
  69.     
  70.     thePICT = OpenPicture( &PICTRect);
  71.     offscreen.copyfrom( offscreen);
  72.     ClosePicture();
  73.     long new_size = GetHandleSize( (Handle)thePICT);
  74.     //
  75.     // Keep the old header
  76.     //
  77.     result = SetFPos( refNum, fsFromStart, 0x0200); 
  78.     result = SetEOF( refNum, new_size + 0x200);
  79.     result = FSWrite( refNum, &new_size, (char *)*thePICT);
  80.     KillPicture( thePICT);
  81.     result = FSClose( refNum);
  82. }
  83.  
  84. void eight_to_one::DoMenu( long retVal)
  85. {
  86.     const short menuID = HiWord( retVal);
  87.     const short itemID = LoWord( retVal);
  88.  
  89.     switch( menuID)
  90.     {
  91.         case kAppleMenuID:
  92.             DoAppleMenu( itemID);
  93.             break;
  94.             
  95.         case kFileMenuID:
  96.             switch( itemID)
  97.             {
  98.                 case kSelectFileItem:
  99.                     SelectFile();
  100.                     break;
  101.                 
  102.                 case kPrefsItem:    // _not_ kQuitItem!!
  103.                     SendQuitToSelf();
  104.                     break;
  105.             }
  106.     }
  107. }
  108.